package com.tienon.message.listener;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.jms.TextMessage;


public class ReceiveMsgListener implements MessageListener{

	@Override
	public void onMessage(Message msg) {
		
		
		System.out.println(msg);
		if(msg instanceof ObjectMessage){
			
			ObjectMessage obj = (ObjectMessage) msg;
			try {
				Object obj1 = obj.getObject();
				System.out.println(obj1);
			} catch (JMSException e) {
				e.printStackTrace();
			}
			
			
		}
		else if(msg instanceof TextMessage){
			
			TextMessage txt = (TextMessage) msg;
			try {
				System.out.println(txt.getText());
			} catch (JMSException e) {
				e.printStackTrace();
			}
			
		}
		
		
		
	}

}
